Ext.define("Skood.controller.UserController",{
	extend:"Ext.app.Controller",
	stores:['UserStore','UserJsonStore'],
	models:['UserModel'],
	views:[
	       'user.UserGrid',
	       'user.UserWindow'
	       ],//在控制器中定了views,会自动从app/view/目录下查找user/UserGrid.js文件
	//Init函数一个最棒的地方是控制器与视图的交互，这里的交互是指控制功能，因为他很容易就可以监听到视图类的事件处理函数，并采取相应的措施，并及时渲染相关信息到面板上来
	init:function(){
		//console.log("Initialized Users! This happend before the Application launch function is called.");
		this.control({
			'viewport > userGrid':{
				render:this.onPanelRendered
			},
			'userGrid':{
				itemdblclick:this.onEditUser
			},
			'userGrid > button:first':{
				click:this.doAdd
			}
		});
	},
	onPanelRendered:function(){
		console.log('This UserGrid is rendered.');
	},
	onEditUser:function( grid, record, item, index, e, eOpts ){
		console.log("Editing user :"+record.get('name')+" ,email:"+record.get("email"));
		console.log(e.getTarget());
		var win = Ext.widget("userWindow");//不在views中加入‘user.UserWindow',就无法动态加载到addEditUserWin
		win.down('form').loadRecord(record);
		win.show();
	}
})